package com.njtech.smartuniversity.controller;

import com.github.pagehelper.PageInfo;
import com.njtech.smartuniversity.bean.AssistantBean;
import com.njtech.smartuniversity.service.AssistantService;
import com.njtech.smartuniversity.bean.UserBean;
import com.njtech.smartuniversity.service.UserService;
import com.njtech.smartuniversity.bean.CaseBean;
import com.njtech.smartuniversity.service.CaseService;
import com.njtech.smartuniversity.service.CaseobjService;
import com.njtech.smartuniversity.bean.CaseobjBean;
import com.njtech.smartuniversity.bean.CaseobjBeanExample;
import com.njtech.smartuniversity.util.JsonResult;
import com.njtech.smartuniversity.util.JsonUtil;
import com.njtech.smartuniversity.util.PdfUtilsPic;
import com.njtech.smartuniversity.util.NumberUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Calendar;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;


/**
 * Created by ritchie on 6/25/18
 */

@RestController
@Api(value = "/api/assistant", tags = {"案件"}, description = "案件相关")
@RequestMapping("/api/assistant")
public class AssistantController {

    @Autowired
    AssistantService mAssistantService;
    @Autowired
    CaseService mCaseService;
    @Autowired
    CaseobjService mCaseobjService;
    @Autowired
    UserService mUserService;

//    @GetMapping("/{id}")
//    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_CUSTOMER') or hasRole('ROLE_MERCHANT')")
//    @ApiOperation(value = "单个用户查询接口", notes = "使用ID查询用户")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "用户ID(学号/工号)", name = "id", dataType = "String", paramType = "path", required = true)
//    })
//    @ApiResponses({
//            @ApiResponse(code = 400, message = "请求参数有误"),
//            @ApiResponse(code = 401, message = "未授权"),
//            @ApiResponse(code = 403, message = "禁止访问"),
//            @ApiResponse(code = 404, message = "请求路径不存在"),
//            @ApiResponse(code = 500, message = "服务器内部错误")
//    })
//    public JsonResult GetUser(@PathVariable("id") String id) {
//        UserBean user = mUserService.selectByUserId(id);
//        if (user != null) {
//            return new JsonUtil().successDataDefault(user);
//        }
//
//        return new JsonUtil().wrongNoDataWithMessage("不存在该地域");
//    }

    @GetMapping("/list/{area_id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "协查列表接口", notes = "获取所有协查信息")
    @ApiImplicitParams({

            @ApiImplicitParam(value = "用户地域", name = "area_id", dataType = "int", paramType = "path")
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult ListCases(
            @PathVariable(value = "area_id") int area_id
    ) {

        List<AssistantBean> areaBeanList = mAssistantService.getAllAssistant(area_id);
        if (areaBeanList != null) {
            return new JsonUtil().successDataDefault(areaBeanList);
        }
        return new JsonUtil().wrongNoDataWithMessage("不存在协查信息");

    }


    @GetMapping("/{area_id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "案件列表分页接口", notes = "获取分页案件信息")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页码", name = "page", dataType = "int", paramType = "form"),
            @ApiImplicitParam(value = "每页数量", name = "size", dataType = "int", paramType = "form"),
            @ApiImplicitParam(value = "用户地域", name = "area_id", dataType = "int", paramType = "path")
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult ListPageUsers(@RequestParam(value = "page", defaultValue = "1") int pageNum,
                                    @RequestParam(value = "size", defaultValue = "10") int pageSize,
                                    @PathVariable(value = "area_id") int area_id) {
        if(area_id==5){
            area_id = 0;
        }
        PageInfo<AssistantBean> pageInfo = mAssistantService.getAssistantByPage(pageNum, pageSize,area_id);
        if (pageInfo != null) {
            return new JsonUtil().successDataDefault(pageInfo);
        }
        return new JsonUtil().wrongNoDataWithMessage("不存在地域信息");

    }

    @DeleteMapping(value = "del/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "案件删除接口", notes = "案件指定ID的用户")
    @ApiImplicitParam(value = "案件ID", name = "id", dataType = "int", paramType = "path", required = true)
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult DeleteCase(@PathVariable("id") int id) {
        boolean result = mAssistantService.deleteById(id);
        if (result) {

            return new JsonUtil().successEmptyDataDefault("删除该案件成功");

        }

        return new JsonUtil().wrongNoDataWithMessage("不存在该案件");

    }


//    @PostMapping(value = "update/{id}")
//    @PreAuthorize("hasRole('ROLE_MERCHANT')")
//    @CrossOrigin
//    @ApiOperation(value = "案件信息修改接口", notes = "修改指定ID的案件信息")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "案件ID", name = "id", dataType = "Integer", paramType = "path", required = true),
//            @ApiImplicitParam(value = "案件名", name = "casename", dataType = "String", paramType = "form"),
//            @ApiImplicitParam(value = "地域id", name = "area_id", dataType = "Integer", paramType = "form"),
//            @ApiImplicitParam(value = "案件编号", name = "numbers", dataType = "String", paramType = "form"),
//            @ApiImplicitParam(value = "案件类别", name = "casetype_id", dataType = "Integer", paramType = "form"),
//            @ApiImplicitParam(value = "使用目的", name = "intendeds", dataType = "String", paramType = "form"),
//            @ApiImplicitParam(value = "联系方式", name = "tel", dataType = "String", paramType = "form"),
//            @ApiImplicitParam(value = "基本情况", name = "basic", dataType = "String", paramType = "form"),
//    })
//    @ApiResponses({
//            @ApiResponse(code = 400, message = "请求参数有误"),
//            @ApiResponse(code = 401, message = "未授权"),
//            @ApiResponse(code = 403, message = "禁止访问"),
//            @ApiResponse(code = 404, message = "请求路径不存在"),
//            @ApiResponse(code = 500, message = "服务器内部错误")
//    })
//    public JsonResult UpdateCase(@PathVariable("id") int id,
//                                 @RequestParam(value = "casename", required = false) String casename,
//                                 @RequestParam(value = "area_id", required = false) int area_id,
//                                 @RequestParam(value = "numbers", required = false) String numbers,
//                                 @RequestParam(value = "casetype_id", required = false) int casetype_id,
//                                 @RequestParam(value = "intendeds", required = false) String intendeds,
//                                 @RequestParam(value = "tel", required = false) String tel,
//                                 @RequestParam(value = "basic", required = false) String basic
//
//    ){
//        CaseBean caseBean= new CaseBean();
//        caseBean.setCasename(casename);
//        caseBean.setArea_id(area_id);
//        caseBean.setNumbers(numbers);
//        caseBean.setCasetype_id(casetype_id);
//        caseBean.setIntendeds(intendeds);
//        caseBean.setTel(tel);
//        caseBean.setBasic(basic);
//        caseBean.setId(id);
//        if(casetype_id == 1){
//            caseBean.setResources("1,2,3,4,5,6");
//        }else{
//            caseBean.setResources("1,2,3");
//        }
//
//        return new JsonUtil().successDataWithMessage(mCaseService.update(caseBean), "修改案件信息成功");
//    }
//
    @GetMapping("/add/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "协查信息添加接口", notes = "添加指定ID的协查信息")
    @ApiImplicitParam(value = "案件ID", name = "id", dataType = "int", paramType = "path")

    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult addCase(@PathVariable("id") int id)

        {
        CaseBean goodsBean = mCaseService.select(id);
        //新增判断改地域数量语句数量，查询改案件的地域然后进行判断是否超过5个，超过禁止生成新的协查
        if(mAssistantService.selectsum(goodsBean.getArea_id())>5){
            return new JsonUtil().wrongNoDataWithMessage("本单位已超过5起案件未签收，请本人或特派员至网警大队签收后再新增查询");
        }
        AssistantBean assistantBean=new AssistantBean();
        assistantBean.setWitid(goodsBean.getWritid());
        assistantBean.setCase_id(goodsBean.getId());
        assistantBean.setCasename(goodsBean.getCasename());
        assistantBean.setArea_id(goodsBean.getArea_id());
        assistantBean.setCasetype(goodsBean.getCasetype_id());
        mAssistantService.addAssistant(assistantBean);

        return new JsonUtil().successDataWithMessage(mAssistantService.countbyid(), "添加协查信息成功，返回协查id");
    }

    @PostMapping(value = "update/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "协查信息补充添加接口", notes = "补充指定ID的协查信息")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "协查ID", name = "id", dataType = "int", paramType = "path"),
            @ApiImplicitParam(value = "承办人2", name = "agent2", dataType = "String", paramType = "form"),
            @ApiImplicitParam(value = "使用目的", name = "md", dataType = "String", paramType = "form"),
            @ApiImplicitParam(value = "承办人1", name = "agent1", dataType = "int", paramType = "form")
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult addCase(@PathVariable("id") int id,
                              @RequestParam(value = "agent2", required = false) String agent2,
                              @RequestParam(value = "agent1", required = false) int agent1,
                              @RequestParam(value = "md", required = false) String md
    )
    {
        //1.先new一个assistant
        AssistantBean assistantBean=new AssistantBean();
        assistantBean.setId(id);
        assistantBean.setMd(md);
        assistantBean.setAgent2(agent2);
        assistantBean.setAgent1(agent1);
        int objnum=0;
        int aimsum=0;
        int specialsum=0;

        //2.根据协查id查询不同种类的目标数量
        List<CaseobjBean> objList = mCaseobjService.getAllCaseobj(id);
        //对象数获取
        //（1）如果for循环（name！=不详 ）objnum++本判断有问题
        for(int i = 0 ; i < objList.size() ; i++) {
            CaseobjBean  caseobjBean =(CaseobjBean) objList.get(i);
            if(!caseobjBean.getNumber().equals("不详")){
                objnum++;
            }
        }
        assistantBean.setObjnum(objnum);
        //目标数获取
        //（2）如果for循环（1<=target_id<=13）aimsum++
        for(int i = 0 ; i < objList.size() ; i++) {
            CaseobjBean  caseobjBean =(CaseobjBean) objList.get(i);
            if(1<=caseobjBean.getTarget_id()&&caseobjBean.getTarget_id()<=13){
                aimsum++;
            }
        }
        assistantBean.setAimsum(aimsum);
        //特定信息数
        //（3）如果for循环（target_id==14）specialsum++
        for(int i = 0 ; i < objList.size() ; i++) {
            CaseobjBean  caseobjBean =(CaseobjBean) objList.get(i);
            if(caseobjBean.getTarget_id()==14){
                specialsum++;
            }
        }

        assistantBean.setSpecialsum(specialsum);

        //计算时间修改状态和计算表格编号
        AssistantBean assistantBean1=mAssistantService.select(id);
        int casetype=assistantBean1.getCasetype();
        Date starttime=new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(starttime);
        if(casetype<3){
            calendar.add(Calendar.DAY_OF_MONTH, +90);//+1今天的时间加90天
        }else{
            calendar.add(Calendar.DAY_OF_MONTH, +30);//+1今天的时间加30天
        }


        Date endtime = calendar.getTime();
        assistantBean.setEndtime(endtime);
        assistantBean.setStrattime(starttime);
        //查询案件的id和案件的类型


        //当前时间字符串：2位年2位月2位日
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
        String dateNowStr = sdf.format(starttime);
        String sxh="";
        //最后四位按照按年计算数量+1
        if(assistantBean1.getSerualsum() !=null){
            sxh=assistantBean1.getSerualsum().substring(assistantBean1.getSerualsum().length()-4);
        }else{
            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
            String year = sdf1.format(starttime);
            int xh=mAssistantService.countbytime(assistantBean1)+1;

            if(xh<10){
                sxh="000"+String.valueOf(xh);
            }else if(xh<100){
                sxh="00"+String.valueOf(xh);
            }else if(xh<1000){
                sxh="0"+String.valueOf(xh);
            }else{
                sxh=String.valueOf(xh);
            }
        }
        //行政：KCWJA+时间+顺序号
        //刑事：KCXJA
        //案事件初查：KCCJA
        //网络安全监督检查：KCJJA
        //信息管控：KCGJA
        //重点人管控：KCZJA
        //组合并上传
        String serualsum="";

        switch(casetype){
            case 1 :
                //语句
                serualsum="KCXJA"+dateNowStr+sxh;
                break; //可选
            case 2 :
                //语句
                serualsum="KCWJA"+dateNowStr+sxh;
                break; //可选
            case 3 :
                //语句
                serualsum="KCCJA"+dateNowStr+sxh;
                break; //可选
            case 4 :
                //语句
                serualsum="KCGJA"+dateNowStr+sxh;
                break; //可选
            case 5 :
                //语句
                serualsum="KCWJA"+dateNowStr+sxh;
                break; //可选
            case 6 :
                //语句
                serualsum="KCZJA"+dateNowStr+sxh;
                break; //可选

        }
        assistantBean.setSerualsum(serualsum);
        assistantBean.setIspdf(1);
        assistantBean.setState(3);
        assistantBean.setPdfurl(serualsum);
        return new JsonUtil().successDataWithMessage(mAssistantService.update(assistantBean), "添加协查信息成功");
    }



    @PostMapping(value = "/gbzt/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "协查信息补充添加接口", notes = "补充指定ID的协查信息")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "协查ID", name = "id", dataType = "int", paramType = "path"),

            @ApiImplicitParam(value = "状态", name = "strat", dataType = "int", paramType = "form")
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public JsonResult addCase(@PathVariable("id") int id,
                              @RequestParam(value = "strat", required = false) int strat

    )
    {
        AssistantBean assistantBean=new AssistantBean();
        assistantBean.setId(id);
        assistantBean.setState(strat);
        if(strat==2){
            CaseBean cases=new CaseBean();
            AssistantBean assistantBean1=mAssistantService.select(id);
            cases.setId(assistantBean1.getCase_id());
            cases.setStlye(2);
            mCaseService.update(cases);
        }

        if(strat==4){
            assistantBean.setGettime(new Date());
        }
        if(strat==5){
            assistantBean.setSigntime(new Date());
        }
        if(strat==6){
            assistantBean.setReplytime(new Date());
        }
        return new JsonUtil().successDataWithMessage(mAssistantService.update(assistantBean), "添加查询信息成功");
    }



    @GetMapping("selcet/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "案件信息接口", notes = "案件详情")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "案件id", name = "id", dataType = "int", paramType = "path", required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })

    public JsonResult GetCase(@PathVariable("id") int id) {
        AssistantBean assistantBean=mAssistantService.select(id);
        if (assistantBean != null) {
            return new JsonUtil().successDataDefault(assistantBean);
        }
        return new JsonUtil().wrongNoDataWithMessage("不存在该查询");
    }


    @GetMapping("pdf/{id}")
    @PreAuthorize("hasRole('ROLE_MERCHANT')")
    @ApiOperation(value = "案件信息接口", notes = "案件详情")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "id", name = "id", dataType = "int", paramType = "path", required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数有误"),
            @ApiResponse(code = 401, message = "未授权"),
            @ApiResponse(code = 403, message = "禁止访问"),
            @ApiResponse(code = 404, message = "请求路径不存在"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })

    public JsonResult GetCasepdf(@PathVariable("id") int id) {
        AssistantBean assistantBean=mAssistantService.select(id);
        if (assistantBean == null) {
            return new JsonUtil().wrongNoDataWithMessage("无法生成正确的pdf");
        }
        if(assistantBean.getIspdf()==2){
            return new JsonUtil().successDataWithMessage(assistantBean.getPdfurl(),"已生成");
        }
        assistantBean.setIspdf(2);

        Map<String,String> sj=new HashMap<>();
        sj.put("serualsum",assistantBean.getSerualsum());//编号
        mAssistantService.update(assistantBean);
        Date starttime=assistantBean.getStrattime();
        Date endtime=assistantBean.getEndtime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");//开始时间
        String dateNowStr = sdf.format(starttime);
        String dateEndStr = sdf.format(endtime);
        sj.put("strattime",dateNowStr);
        sj.put("time",dateNowStr+"至"+dateEndStr);
        sj.put("casename",assistantBean.getCasename());
        String casetypeStr="";
        String resources="";
        switch(assistantBean.getCasetype()){
            case 1 :
                casetypeStr="刑事案件";
                resources="公开数据、身份数据、地址数据、群聊数据、行为数据、轨迹数据";
                break;
            case 2 :
                casetypeStr="行政案件";
                resources="公开数据、身份数据、地址数据、群聊数据、行为数据、轨迹数据";
                break;
            case 3 :
                casetypeStr="案事件初查";
                resources="公开数据、身份数据、地址数据";
                break;
            case 4 :
                casetypeStr="网络安全监督检查";
                resources="公开数据、身份数据、地址数据";
                break;
            case 5 :
                casetypeStr="信息管控";
                resources="公开数据、身份数据、地址数据、群聊数据、行为数据、轨迹数据";
                break;
            case 6 :
                casetypeStr="重点人管控";
                resources="公开数据、身份数据、地址数据、群聊数据、行为数据、轨迹数据";
                break;

        }
        sj.put("casetype",casetypeStr);
        sj.put("resources",resources);
        sj.put("witid",assistantBean.getWitid());
        UserBean userBean=new UserBean();
        userBean.setId( Integer.toString(assistantBean.getAgent1()));
        userBean=mUserService.selectByid(userBean);
        String agent1Name=userBean.getAgent1Name();
        String agent=agent1Name+","+assistantBean.getAgent2();
        sj.put("agent",agent);
        sj.put("area",userBean.getArea());//地点
        sj.put("tel",userBean.getPhone());
        CaseBean caseBean = mCaseService.select(assistantBean.getCase_id());
        sj.put("basic",caseBean.getBasic());
        sj.put("md",assistantBean.getMd());
        sj.put("objnum",NumberUtil.int2chineseNum(assistantBean.getObjnum()));
        sj.put("aimsum",NumberUtil.int2chineseNum(assistantBean.getAimsum()));
        sj.put("specialsum",NumberUtil.int2chineseNum(assistantBean.getSpecialsum()));
        //对象导入工程
        List<CaseobjBean> objList = mCaseobjService.getAllCaseobj(id);
        for(int i = 0 ; i < objList.size() ; i++) {
            CaseobjBean  caseobjBean =(CaseobjBean) objList.get(i);
            sj.put("xh"+(i+1), Integer.toString(i+1));
            sj.put("name"+(i+1),caseobjBean.getName());
            if(caseobjBean.getObjecttype_id()==1){
                sj.put("sfz"+(i+1),"身份证："+caseobjBean.getNumber());
            }else{
                sj.put("sfz"+(i+1),"护照号："+caseobjBean.getNumber());
            }
            switch(caseobjBean.getTarget_id()) {
                case 1:
                    sj.put("taget"+(i+1),"手机号："+caseobjBean.getTaget());
                    break;
                case 2:
                    sj.put("taget"+(i+1),"微信号："+caseobjBean.getTaget());
                    break;
                case 3:
                    sj.put("taget"+(i+1),"微信id："+caseobjBean.getTaget());
                    break;
                case 4:
                    sj.put("taget"+(i+1),"微信群id："+caseobjBean.getTaget());
                    break;
                case 5:
                    sj.put("taget"+(i+1),"QQ："+caseobjBean.getTaget());
                    break;
                case 7:
                    sj.put("taget"+(i+1),"QQ群号："+caseobjBean.getTaget());
                    break;
                case 8:
                    sj.put("taget"+(i+1),"IP："+caseobjBean.getTaget());
                    break;
                case 9:
                    sj.put("taget"+(i+1),"IMEI："+caseobjBean.getTaget());
                    break;
                case 10:
                    sj.put("taget"+(i+1),"IMSI："+caseobjBean.getTaget());
                    break;
                case 11:
                    sj.put("taget"+(i+1),"MAC："+caseobjBean.getTaget());
                    break;
                case 12:
                    sj.put("taget"+(i+1),"微博ID："+caseobjBean.getTaget());
                    break;
                case 13:
                    sj.put("taget"+(i+1),"其他虚拟身份："+caseobjBean.getTaget());
                    break;
                case 14:
                    sj.put("taget"+(i+1),"关键字："+caseobjBean.getTaget());
                    break;
            }

        }
        if(objList.size()<10){
            sj.put("taget"+(objList.size()+1),"以下空白");
        }


        String modalfile="/www/wwwroot/wjxc-web/pages/system/cun/pdf/1.pdf";


        String NewFile="/www/wwwroot/wjxc-web/pages/system/cun/pdf/"+assistantBean.getPdfurl()+".pdf";
        PdfUtilsPic.pdfout(sj,modalfile,NewFile);
        String modalfile1="/www/wwwroot/wjxc-web/pages/system/cun/pdf/2.pdf";
        String NewFile2="/www/wwwroot/wjxc-web/pages/system/cun/pdfxz/"+assistantBean.getPdfurl()+".pdf";
        PdfUtilsPic.pdfout(sj,modalfile1,NewFile2);

        return new JsonUtil().successDataWithMessage(assistantBean.getPdfurl(),"生成pdf成功");
    }
//
//    @GetMapping("text"hasRole('ROLE_MERCHANT')")
//    @ApiOperation(value = "案件信息接口", notes = "案件详情")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "id", name = "id", dataType = "int", paramType = "path", required = true)
//    })
//    @ApiResponses({
//            @ApiResponse(code = 400, message = "请求参数有误"),
//            @ApiResponse(code = 401, message = "未授权"),
//            @ApiResponse(code = 403, message = "禁止访问"),
//            @ApiResponse(code = 404, message = "请求路径不存在"),
//            @ApiResponse(code = 500, message = "服务器内部错误")
//    })
//
//    public JsonResult GetCasetext(@PathVariable("id") int id) {
//        AssistantBean assistantBean=mAssistantService.select(id);
//
//
//        try {
//
//            // 保存路径
//            String path = "/www/wwwroot/wjxc-web/pages/system/cun/pdf/";
//            String title = "一个TXT";
//            String content = "一段话";
//            // 防止文件建立或读取失败，用catch捕捉错误并打印，也可以throw
//            /* 写入Txt文件 */
//            File mkdirsName = new File(path);// 相对路径，如果没有则要建立一个新的output。txt文件
//            if(!mkdirsName.exists()){
//                mkdirsName.mkdirs();
//            }
//            File writename = new File(path+"\\"+title+".txt");// 相对路径，如果没有则要建立一个新的output。txt文件
//            // 判断文件是否存在，不存在即新建
//            // 存在即根据操作系统添加换行符
//            if(!writename.exists()) {
//                writename.createNewFile(); // 创建新文件
//            } else {
//                String osName = System.getProperties().getProperty("os.name");
//                if (osName.equals("Linux")) {
//                    content = "\r" + content;
//                } else {
//                    content = "\r\n" + content;
//                }
//            }
//            // 如果是在原有基础上写入则append属性为true，默认为false
//            BufferedWriter out = new BufferedWriter(new FileWriter(writename,true));
//            out.write(content); // 写入TXT
//            out.flush(); // 把缓存区内容压入文件
//            out.close(); // 最后记得关闭文件
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//        return new JsonUtil().successDataWithMessage(assistantBean.getPdfurl(),"生成text成功");
//    }




}
